#ifndef ELK_RESOURCE_VIEW_H
#define ELK_RESOURCE_VIEW_H

#include <QWidget>
#include <QStandardItemModel>
#include "elk_web_delegate.h"

namespace Ui {
class ElkResourceView;
}

class ElkResourceView : public QWidget
{
    Q_OBJECT

public:
    explicit ElkResourceView(QWidget *parent = nullptr);
    ~ElkResourceView();

    void bind(QWeakPointer<ElkWebDelegate> delegate);
    void request(const QString &frame, const ElkRequestDetails &details);

private slots:
    void onBeforeBrowser(const QString &frame,
                         const ElkRequestDetails &details,
                         bool userGesture, bool isRedirect);
    void onResourceRequested(const QString &frame,
                             const ElkRequestDetails &details);

    void on_pushButtonClear_clicked();
    void on_pushButtonDownload_clicked();
    void on_tableView_doubleClicked(const QModelIndex &index);

    void on_radioButtonAll_toggled(bool checked);
    void on_checkBoxXhr_toggled(bool checked);
    void on_checkBoxScript_toggled(bool checked);
    void on_checkBoxStylesheet_toggled(bool checked);
    void on_checkBoxImage_toggled(bool checked);
    void on_checkBoxMedia_toggled(bool checked);

private:
    void updateResourceTypeSelection();

private:
    Ui::ElkResourceView *ui;
    QStandardItemModel *model_ = nullptr;
    QString resourceTypeSelected_;
    QVector<ElkRequestDetails> requests_;
    QWeakPointer<ElkWebDelegate> delegate_;
};

#endif // ELK_RESOURCE_VIEW_H
